package com.siterwell.push.mongodao;

import com.siterwell.push.entity.DevLog;
import com.siterwell.push.entity.JPushLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class MongoDevLogDao {
    @Autowired
    private MongoTemplate mongoTemplate;

    //批量导入数据
    public void saveDevLogs(List<DevLog> list){
        mongoTemplate.insert(list,DevLog.class);
    }

    public void saveDevLog(DevLog devLog){
        mongoTemplate.save(devLog);
    }




    public List<DevLog> getDevLog(String devTid){
        Query query = new Query(Criteria.where("devTid").is(devTid));
        query.with(new Sort(Sort.Direction.DESC,"createTime"));
        return mongoTemplate.find(query,DevLog.class);
    }


}

